package wql.boot.wqlspringboot02.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import wql.boot.wqlspringboot02.entity.AliPay;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wql
 * @version 1.0
 * @date 2022/11/15 17:10
 */
@RestController
@RequestMapping("/user")
public class HaHaController {
    @GetMapping("/user")
    public Map index() {
        Map map = new HashMap();
        map.put("name", "王乾龙");
        map.put("age", 19);
        return map;
    }
    @Autowired
    private AliPay aliPay;
    @GetMapping("/alipay")
    public AliPay alipay(){
        return aliPay;
    }
    @Value("${server.port}")
    private Integer port;

    @Value("${student.name}")
    private String name;
    @GetMapping("/haha")
    public String haha(){
        return "端口号"+ port+"姓名"+name;
    }

    @GetMapping("/request")
    public String getRequestInfo(HttpServletRequest request) {
        System.out.println(request.getAttribute("name"));
        return "成功拿到数据";
    }
}
